﻿using KingsSharp.Core.Data.Entity.Migrations;
using CRM.Admin.Contracts.Model.Sys;
using System;
using System.Collections.Generic;
using System.Data.Entity;

namespace CRM.Admin.Services.Seeds
{
    public class MenuSeedAction : ISeedAction
    {
        /// <summary>
        /// 获取 操作排序，数值越小越先执行
        /// </summary>
        public int Order { get { return 1; } }
        /// <summary>
        /// 定义种子数据初始化过程
        /// </summary>
        /// <param name="context">数据上下文</param>
        public void Action(DbContext context)
        {
            MenuCatalog entity = new MenuCatalog()
            {
                Id = Guid.NewGuid(),
                Name = "系统设置",
                Order = 99,
                Type = 99,
                IconText = "&#xe60a;",
                IconColor = "#7B8AB5",
                Menus = new List<MenuNode>() {
                    new MenuNode()
                    {
                        Id = Guid.NewGuid(),
                        Name = "菜单设置",
                        Description = "设置整个系统所用到的菜单",
                        MenuCode = Guid.NewGuid().ToString(),
                        MenuURL = "~/Sys/Menu/MenuIndex",
                        IconText = "&#xe630;",
                        IconColor="#7B8AB5",
                        Order = 1,
                        Type = 99
                  }
                }
            };
            context.Set<MenuCatalog>().Add(entity);
        }
    }
}

